package br.com.mongo;

import java.net.UnknownHostException;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public class MongoTest {
	
	public static void main(String[] args) {
		try {
			Mongo mongo = new Mongo();
			DB db = mongo.getDB("test");
			for (String string : db.getCollectionNames()) {
				System.out.println(string);
			}
			
			DBCollection coll = db.getCollection("gui");
			
			BasicDBObject doc = new BasicDBObject();
			doc.put("nome", "Guilherme H. Bueno");
			doc.put("site", "www.simuladosdevestibulares.com.br");

			BasicDBObject info = new BasicDBObject();
			info.put("xpto", "zapata");

			doc.put("info", info);
			coll.insert(doc);
			
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (MongoException e) {
			e.printStackTrace();
		}
	}

}
